pkgname=firmware-qcom-adreno
pkgver=20241110
pkgrel=0
pkgdesc="Qualcomm Adreno GPU firmware from linux-firmware"
url="https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/"
arch="aarch64 armv7"
license="custom"
subpackages="$pkgname-doc"
source="https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/snapshot/linux-firmware-$pkgver.tar.gz"
options="!check !strip !archcheck !tracedeps pmb:cross-native"
builddir="$srcdir/linux-firmware-$pkgver"

# This package is a replacement for linux-firmware-qcom (packaging all GPU firmware
# in separate subpackages), so it's packaged in /qcom, not /postmarketos.
replaces="linux-firmware-qcom"
_fwdir="/lib/firmware/qcom"

_gpus="a300 a330 a420 a530 a630 a650 a660 gen70500"
for gpu in $_gpus; do
	subpackages="$subpackages $pkgname-$gpu:_gpu"
done

package() {
	install -Dm644 LICENSE.qcom "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
	install -Dm644 qcom/NOTICE.txt "$pkgdir"/usr/share/licenses/$pkgname/NOTICE
}

_gpu() {
	local gpu=${subpkgname##$pkgname-}
	pkgdesc="$pkgdesc ($gpu)"

	install -Dm644 "$builddir"/qcom/$gpu* -t "$subpkgdir/$_fwdir"/

	# Drop _zap shader firmware because that is typically signed
	# and therefore device-specific.
	rm -f "$subpkgdir/$_fwdir/$gpu"_zap*
}

sha512sums="
b4ae2abe6eecc5e8fdc796ae75394d936fee7f7b5ed7803c51eccdbfba1f883ac567a43adc9e7c3a4e4934bf1794e37cd93478468599b542ef1327a8221f648a  linux-firmware-20241110.tar.gz
"
